// let newObj = {}
// newObj[Symbol.iterator] = function* () {
//   yield 1 + 1
//   yield 1 + 2
//   yield 1 + 3
// }
// for (let v of newObj) {
//   console.log('==', v)
// }
// console.log([...newObj])

function* fibonacci() {
  let [prev, curr] = [0, 1]
  for (let n = 1; ; n++) {
    yield { n, curr }
    ;[prev, curr] = [curr, prev + curr]
  }
}

for (let v of fibonacci()) {
  let { n, curr } = v
  if (n > 10) break
  console.log(n, '=', curr)
}
